package com.qianniu.napi.admin.service.akka;

import akka.actor.UntypedActor;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.qianniu.napi.admin.entity.*;
import com.qianniu.napi.admin.entity.penum.*;
import com.qianniu.napi.admin.service.*;
import com.qianniu.napi.common.config.Constants;
import com.qianniu.napi.common.util.SpringUtil;
import com.qianniu.napi.common.util.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.math.BigDecimal;

public class FanActor extends UntypedActor {

    private final static Logger logger = LoggerFactory.getLogger("actorlog");

    private IUserService userService = (IUserService) SpringUtil.getBean("userServiceImpl");
    private IUserstatService userstatService = (IUserstatService) SpringUtil.getBean("userstatServiceImpl");
    private IFensService fensService = (IFensService) SpringUtil.getBean("fensServiceImpl");
    private IRedisService redisService = (IRedisService) SpringUtil.getBean("redisServiceImpl");
    private IJifenService jifenService = (IJifenService) SpringUtil.getBean("jifenServiceImpl");
    private IJifenFlowService jifenFlowService = (IJifenFlowService) SpringUtil.getBean("jifenFlowServiceImpl");
    private IAccountService accountService = (IAccountService) SpringUtil.getBean("accountServiceImpl");
    private IAccountFlowService accountFlowService = (IAccountFlowService) SpringUtil.getBean("accountFlowServiceImpl");
    private IXnbiService xnbiService = (IXnbiService) SpringUtil.getBean("xnbiServiceImpl");
    private IXnbiFlowService xnbiFlowService = (IXnbiFlowService) SpringUtil.getBean("xnbiFlowServiceImpl");
    private IMerchantConfigService merchantConfigService = (IMerchantConfigService) SpringUtil.getBean("merchantConfigServiceImpl");

    @Override
    public void onReceive(Object message) {

        String msg = message.toString();
        logger.debug(">>>>>> FanActor receive message:" + msg);

        // 格式 type+uid+mpid
        String[] arr = msg.split("@");
        if (arr.length < 3) return;
        try {

            String type = arr[0];
            String uid = arr[1];
            String mpid = arr[2];
            String ywid = arr.length>3? arr[3]:null;
            switch (type) {
                case Constants.AKKA_MSG_REGIST:
                    registFan(Long.valueOf(uid), Long.valueOf(mpid));
                    break;
                case Constants.AKKA_MSG_BIND_PHONE:
                    bindPhoneFan(Long.valueOf(uid), Long.valueOf(mpid));
                    break;
                case Constants.AKKA_MSG_SIGN_FAN:
                    signFan(Long.valueOf(uid), Long.valueOf(mpid));
                    break;
                case Constants.AKKA_MSG_READING_FAN:
                    readingFan(Long.valueOf(uid), Long.valueOf(mpid),ywid);
                    break;
                case Constants.AKKA_MSG_DIANZAN:
                    dianzanFan(Long.valueOf(uid), Long.valueOf(mpid),ywid);
                    break;
                case Constants.AKKA_MSG_PINGLUN:
                    pinglunFan(Long.valueOf(uid), Long.valueOf(mpid),ywid);
                    break;
                case Constants.AKKA_MSG_YUYUE:
                    yuyueFan(Long.valueOf(uid), Long.valueOf(mpid),ywid);
                    break;
                case Constants.AKKA_MSG_HEXIAO_FAN:
                    hexiaoFan(Long.valueOf(uid), Long.valueOf(mpid),ywid);
                    break;
                default:
                    return;
            }

        } catch (Exception e) {
            logger.error("----------------error happen", e);
        }

    }

    // 自己注册奖励
    private void registFan(Long uid, Long mpid) {
        logger.info("---------------------------------------------------------registFan come in");
        FanConfig fconfig = redisService.getFanconfig(mpid);
        if (fconfig == null) {
            logger.info("---------------------------------------------------------------------registFan fconfig is null");
            return;
        }
        BigDecimal fan = fconfig.getZhuceMount();
        Integer type = fconfig.getZhuceType();

        if (type == null || type == 0) {
            logger.info("---------------------------------------------------------------------registFan type=" + type);
            return;
        }

        User user = userService.selectById(uid);
        logger.info("----------------------------------------------------------registFan user=" + JSON.toJSONString(user));

        if (type.intValue() == XffanType.jifen.getVal()) {

            jifenService.addJifenFlow(uid, user.getMid(), mpid,
                    fan, true, FantimeType.now.getVal(),
                    StringUtil.getSnNo(), IotypeEnum.input, JftypeEnum.regist, "", 0l);
        } else if (type.intValue() == XffanType.xnbi.getVal()) {

            xnbiService.addXnbiFlow(uid, user.getMid(), mpid,
                    fan, true, FantimeType.now.getVal(),
                    StringUtil.getSnNo(), IotypeEnum.input, JftypeEnum.regist, "", 0l);
        } else if (type.intValue() == XffanType.qian.getVal()) {

            accountService.addAccountFlow(uid, user.getMid(), mpid,
                    fan, true, FantimeType.now.getVal(),
                    StringUtil.getSnNo(), IotypeEnum.input, XftypeEnum.regist, "", 0l);
        }

    }

    // 父级注册奖励
    private void registFanUpper(Long uid, Long mpid) {

    }

    // 自己绑定手机奖励
    private void bindPhoneFan(Long uid, Long mpid) {
        logger.info("----------------------------------------------------------------------------bindPhoneFan come in");
        User user = userService.selectById(uid);

        FanConfig fconfig = redisService.getFanconfig(mpid);
        if (fconfig == null) {
            logger.info("----------------------------------------------------------------------------bindPhoneFan fconfig is null");
            return;
        }
        if (fconfig.getShoujifanType() == null || fconfig.getShoujifanType() == 0) {
            logger.info("----------------------------------------------------------------------------bindPhoneFan fconfig is null");
            return;
        }

        BigDecimal fan = fconfig.getShoujifanMount();
        Integer type = fconfig.getShoujifanType();

        if (type.intValue() == XffanType.jifen.getVal()) {
            jifenService.addJifenFlow(uid, user.getMid(), mpid,
                    fan, true, FantimeType.now.getVal(),
                    StringUtil.getSnNo(), IotypeEnum.input, JftypeEnum.bindphone, "", 0l);
        } else if (type.intValue() == XffanType.xnbi.getVal()) {
            xnbiService.addXnbiFlow(uid, user.getMid(), mpid,
                    fan, true, FantimeType.now.getVal(),
                    StringUtil.getSnNo(), IotypeEnum.input, JftypeEnum.bindphone, "", 0l);
        } else if (type.intValue() == XffanType.qian.getVal()) {


            accountService.addAccountFlow(uid, user.getMid(), mpid,
                    fan, true, FantimeType.now.getVal(),
                    StringUtil.getSnNo(), IotypeEnum.input, XftypeEnum.bindphone, "", 0l);
        }

    }

    // 每日签到奖励
    private void signFan(Long uid, Long mpid) {

        logger.info("----------------------------------------------------------------------------signFan come in");
        User user = userService.selectById(uid);

        FanConfig fconfig = redisService.getFanconfig(mpid);
        if (fconfig == null) {
            logger.info("----------------------------------------------------------------------------signFan fconfig is null");
            return;
        }
        if (fconfig.getSignfanType() == null || fconfig.getSignfanType() == 0) {
            logger.info("----------------------------------------------------------------------------signFan fconfig is null");
            return;
        }

        BigDecimal fan = fconfig.getSignfanMount();
        Integer type = fconfig.getSignfanType();

        if (type.intValue() == XffanType.jifen.getVal()) {

            jifenService.addJifenFlow(uid, user.getMid(), mpid,
                    fan, true, FantimeType.now.getVal(),
                    StringUtil.getSnNo(), IotypeEnum.input, JftypeEnum.qiandao, "", 0l);
        } else if (type.intValue() == XffanType.xnbi.getVal()) {

            xnbiService.addXnbiFlow(uid, user.getMid(), mpid,
                    fan, true, FantimeType.now.getVal(),
                    StringUtil.getSnNo(), IotypeEnum.input, JftypeEnum.qiandao, "", 0l);
        } else if (type.intValue() == XffanType.qian.getVal()) {

            accountService.addAccountFlow(uid, user.getMid(), mpid,
                    fan, true, FantimeType.now.getVal(),
                    StringUtil.getSnNo(), IotypeEnum.input, XftypeEnum.qiandao, "", 0l);
        }
    }

    // 每日阅读资讯奖励
    private void readingFan(Long uid, Long mpid,String ywid) {

        logger.info("----------------------------------------------------------------------------bindPhoneFan come in");
        User user = userService.selectById(uid);

        FanConfig fconfig = redisService.getFanconfig(mpid);
        if (fconfig == null) {
            logger.info("---------------------------------------------------------------------readingFan fconfig is null");
            return;
        }
        BigDecimal fan = fconfig.getReadfanMount();
        Integer type = fconfig.getReadfanType();
        Integer max = fconfig.getReadfanMax();
        int cout = 0;

        if (fconfig == null) {
            logger.info("----------------------------------------------------------------------------readingFan fconfig is null");
            return;
        }
        if (type == null || type == 0) {
            logger.info("----------------------------------------------------------------------------readingFan fconfig is null");
            return;
        }
        if (max == null || max == 0) {
            logger.info("----------------------------------------------------------------------------readingFan max is null");
            return;
        }

        if (type.intValue() == XffanType.jifen.getVal()) {
            //同一动态是否已点赞过
            cout = jifenFlowService.selectCount(new EntityWrapper<JifenFlow>()
                    .eq("uid", uid).eq("jftype", JftypeEnum.pinglun.getVal()).eq("ywid",ywid)
            );
            if (cout >0) {
                logger.info("----------------------------------readingFan for ywid=" + ywid + " has happen");
                return;
            }
            //校验阅读奖励次数 max
            cout = jifenFlowService.selectCount(new EntityWrapper<JifenFlow>()
                    .eq("uid", uid).eq("jftype", JftypeEnum.yuedu.getVal())
                    .addFilter("date(confirm_date)=date(now())")
            );
            if (cout >= max) {
                logger.info("----------------------------------readingFan max=" + max + " cout=" + cout);
                return;
            }
            jifenService.addJifenFlow(uid, user.getMid(), mpid,
                    fan, true, FantimeType.now.getVal(),
                    StringUtil.getSnNo(), IotypeEnum.input, JftypeEnum.yuedu, null, Long.parseLong(ywid));
        } else if (type.intValue() == XffanType.xnbi.getVal()) {

            //同一动态是否已点赞过
            cout = xnbiFlowService.selectCount(new EntityWrapper<XnbiFlow>()
                    .eq("uid", uid).eq("jftype", JftypeEnum.pinglun.getVal()).eq("ywid",ywid)
            );
            if (cout >0) {
                logger.info("----------------------------------readingFan for ywid=" + ywid + " has happen");
                return;
            }
            //校验阅读奖励次数 max
            cout = xnbiFlowService.selectCount(new EntityWrapper<XnbiFlow>()
                    .eq("uid", uid).eq("jftype", JftypeEnum.yuedu.getVal())
                    .addFilter("date(confirm_date)=date(now())")
            );

            if (cout >= max) {
                logger.info("----------------------------------readingFan max=" + max + " cout=" + cout);
                return;
            }
            xnbiService.addXnbiFlow(uid, user.getMid(), mpid,
                    fan, true, FantimeType.now.getVal(),
                    StringUtil.getSnNo(), IotypeEnum.input, JftypeEnum.yuedu, null, Long.parseLong(ywid));
        } else if (type.intValue() == XffanType.qian.getVal()) {
            //同一动态是否已点赞过
            cout = accountFlowService.selectCount(new EntityWrapper<AccountFlow>()
                    .eq("uid", uid).eq("xftype", XftypeEnum.pinglun.getVal()).eq("origin",ywid)
            );
            if (cout >0) {
                logger.info("----------------------------------readingFan for ywid=" + ywid + " has happen");
                return;
            }
            //校验阅读奖励次数 max
            cout = accountFlowService.selectCount(new EntityWrapper<AccountFlow>()
                    .eq("uid", uid).eq("xftype", XftypeEnum.yuedu.getVal())
                    .addFilter("date(confirm_date)=date(now())")
            );
            if (cout >= max) {
                logger.info("----------------------------------readingFan max=" + max + " cout=" + cout);
                return;
            }
            accountService.addAccountFlow(uid, user.getMid(), mpid,
                    fan, true, FantimeType.now.getVal(),
                    StringUtil.getSnNo(), IotypeEnum.input, XftypeEnum.yuedu, null, Long.parseLong(ywid));
        }

    }

    // 每日点赞
    private void dianzanFan(Long uid, Long mpid,String ywid) {

        logger.info("----------------------------------------------------------------------------dianzanFan come in");
        User user = userService.selectById(uid);

        FanConfig fconfig = redisService.getFanconfig(mpid);
        if (fconfig == null) {
            logger.info("---------------------------------------------------------------------dianzanFan fconfig is null");
            return;
        }
        BigDecimal fan = fconfig.getZanMount();
        Integer type = fconfig.getZanType();
        Integer max = fconfig.getZanMax();
        int cout = 0;

        if (fconfig == null) {
            logger.info("----------------------------------------------------------------------------dianzanFan fconfig is null");
            return;
        }
        if (type == null || type == 0) {
            logger.info("----------------------------------------------------------------------------dianzanFan fconfig is null");
            return;
        }
        if (max == null || max == 0) {
            logger.info("----------------------------------------------------------------------------dianzanFan max is null");
            return;
        }

        if (type.intValue() == XffanType.jifen.getVal()) {
            //同一动态是否已点赞过
            cout = jifenFlowService.selectCount(new EntityWrapper<JifenFlow>()
                    .eq("uid", uid).eq("jftype", JftypeEnum.pinglun.getVal()).eq("ywid",ywid)
            );
            if (cout >0) {
                logger.info("----------------------------------dianzanFan for ywid=" + ywid + " has happen");
                return;
            }
            //校验阅读奖励次数 max
            cout = jifenFlowService.selectCount(new EntityWrapper<JifenFlow>()
                    .eq("uid", uid).eq("jftype", JftypeEnum.dianzan.getVal())
                    .addFilter("date(confirm_date)=date(now())")
            );
            if (cout >= max) {
                logger.info("----------------------------------dianzanFan max=" + max + " cout=" + cout);
                return;
            }

            jifenService.addJifenFlow(uid, user.getMid(), mpid,
                    fan, true, FantimeType.now.getVal(),
                    StringUtil.getSnNo(), IotypeEnum.input, JftypeEnum.dianzan, null, Long.parseLong(ywid));
        } else if (type.intValue() == XffanType.xnbi.getVal()) {
            //同一动态是否已点赞过
            cout = xnbiFlowService.selectCount(new EntityWrapper<XnbiFlow>()
                    .eq("uid", uid).eq("jftype", JftypeEnum.pinglun.getVal()).eq("ywid",ywid)
            );
            if (cout >0) {
                logger.info("----------------------------------dianzanFan for ywid=" + ywid + " has happen");
                return;
            }
            //校验阅读奖励次数 max
            cout = xnbiFlowService.selectCount(new EntityWrapper<XnbiFlow>()
                    .eq("uid", uid).eq("jftype", JftypeEnum.dianzan.getVal())
                    .addFilter("date(confirm_date)=date(now())")
            );

            if (cout >= max) {
                logger.info("----------------------------------dianzanFan max=" + max + " cout=" + cout);
                return;
            }
            xnbiService.addXnbiFlow(uid, user.getMid(), mpid,
                    fan, true, FantimeType.now.getVal(),
                    StringUtil.getSnNo(), IotypeEnum.input, JftypeEnum.dianzan, null, Long.parseLong(ywid));
        } else if (type.intValue() == XffanType.qian.getVal()) {
            //同一动态是否已点赞过
            cout = accountFlowService.selectCount(new EntityWrapper<AccountFlow>()
                    .eq("uid", uid).eq("xftype", XftypeEnum.pinglun.getVal()).eq("origin",ywid)
            );
            if (cout >0) {
                logger.info("----------------------------------dianzanFan for ywid=" + ywid + " has happen");
                return;
            }
            //校验阅读奖励次数 max
            cout = accountFlowService.selectCount(new EntityWrapper<AccountFlow>()
                    .eq("uid", uid).eq("xftype", XftypeEnum.dianzan.getVal())
                    .addFilter("date(confirm_date)=date(now())")
            );
            if (cout >= max) {
                logger.info("----------------------------------dianzanFan max=" + max + " cout=" + cout);
                return;
            }
            accountService.addAccountFlow(uid, user.getMid(), mpid,
                    fan, true, FantimeType.now.getVal(),
                    StringUtil.getSnNo(), IotypeEnum.input, XftypeEnum.dianzan, null, Long.parseLong(ywid));
        }
    }

    // 每日评论
    private void pinglunFan(Long uid, Long mpid,String ywid) {

        logger.info("----------------------------------------------------------------------------pinglunFan come in");
        User user = userService.selectById(uid);

        FanConfig fconfig = redisService.getFanconfig(mpid);
        if (fconfig == null) {
            logger.info("---------------------------------------------------------------------pinglunFan fconfig is null");
            return;
        }
        BigDecimal fan = fconfig.getPingMount();
        Integer type = fconfig.getPingType();
        Integer max = fconfig.getPingMax();

        int cout = 0;

        if (fconfig == null) {
            logger.info("----------------------------------------------------------------------------pinglunFan fconfig is null");
            return;
        }
        if (type == null || type == 0) {
            logger.info("----------------------------------------------------------------------------pinglunFan fconfig is null");
            return;
        }
        if (max == null || max == 0) {
            logger.info("----------------------------------------------------------------------------pinglunFan max is null");
            return;
        }

        if (type.intValue() == XffanType.jifen.getVal()) {

            //同一动态是否已点赞过
            cout = jifenFlowService.selectCount(new EntityWrapper<JifenFlow>()
                    .eq("uid", uid).eq("jftype", JftypeEnum.pinglun.getVal()).eq("ywid",ywid)
            );
            if (cout >0) {
                logger.info("----------------------------------pinglunFan for ywid=" + ywid + " has happen");
                return;
            }
            //校验阅读奖励次数 max
            cout = jifenFlowService.selectCount(new EntityWrapper<JifenFlow>()
                    .eq("uid", uid).eq("jftype", JftypeEnum.pinglun.getVal())
                    .addFilter("date(confirm_date)=date(now())")
            );
            if (cout >= max) {
                logger.info("----------------------------------pinglunFan max=" + max + " cout=" + cout);
                return;
            }

            jifenService.addJifenFlow(uid, user.getMid(), mpid,
                    fan, true, FantimeType.now.getVal(),
                    StringUtil.getSnNo(), IotypeEnum.input, JftypeEnum.pinglun, null, Long.parseLong(ywid));
        } else if (type.intValue() == XffanType.xnbi.getVal()) {
            //同一动态是否已点赞过
            cout = xnbiFlowService.selectCount(new EntityWrapper<XnbiFlow>()
                    .eq("uid", uid).eq("jftype", JftypeEnum.pinglun.getVal()).eq("ywid",ywid)
            );
            if (cout >0) {
                logger.info("----------------------------------pinglunFan for ywid=" + ywid + " has happen");
                return;
            }
            //校验阅读奖励次数 max
            cout = xnbiFlowService.selectCount(new EntityWrapper<XnbiFlow>()
                    .eq("uid", uid).eq("jftype", JftypeEnum.pinglun.getVal())
                    .addFilter("date(confirm_date)=date(now())")
            );

            if (cout >= max) {
                logger.info("----------------------------------pinglunFan max=" + max + " cout=" + cout);
                return;
            }
            xnbiService.addXnbiFlow(uid, user.getMid(), mpid,
                    fan, true, FantimeType.now.getVal(),
                    StringUtil.getSnNo(), IotypeEnum.input, JftypeEnum.pinglun, null, Long.parseLong(ywid));

        } else if (type.intValue() == XffanType.qian.getVal()) {
            //同一动态是否已点赞过
            cout = accountFlowService.selectCount(new EntityWrapper<AccountFlow>()
                    .eq("uid", uid).eq("xftype", XftypeEnum.pinglun.getVal()).eq("origin",ywid)
            );
            if (cout >0) {
                logger.info("----------------------------------pinglunFan for ywid=" + ywid + " has happen");
                return;
            }
            //校验阅读奖励次数 max
            cout = accountFlowService.selectCount(new EntityWrapper<AccountFlow>()
                    .eq("uid", uid).eq("xftype", XftypeEnum.pinglun.getVal())
                    .addFilter("date(confirm_date)=date(now())")
            );
            if (cout >= max) {
                logger.info("----------------------------------pinglunFan max=" + max + " cout=" + cout);
                return;
            }
            accountService.addAccountFlow(uid, user.getMid(), mpid,
                    fan, true, FantimeType.now.getVal(),
                    StringUtil.getSnNo(), IotypeEnum.input, XftypeEnum.pinglun, null, Long.parseLong(ywid));
        }
    }

    // 每日评论
    private void yuyueFan(Long uid, Long mpid,String ywid) {

        logger.info("----------------------------------------------------------------------------yuyueFan come in");
        User user = userService.selectById(uid);

        FanConfig fconfig = redisService.getFanconfig(mpid);
        if (fconfig == null) {
            logger.info("---------------------------------------------------------------------yuyueFan fconfig is null");
            return;
        }
        BigDecimal fan = fconfig.getYuyueMount();
        Integer type = fconfig.getYuyueType();
        Integer max = fconfig.getYuyueMax();
        int cout = 0;

        if (fconfig == null) {
            logger.info("----------------------------------------------------------------------------yuyueFan fconfig is null");
            return;
        }
        if (type == null || type == 0) {
            logger.info("----------------------------------------------------------------------------yuyueFan fconfig is null");
            return;
        }
        if (max == null || max == 0) {
            logger.info("----------------------------------------------------------------------------yuyueFan max is null");
            return;
        }

        if (type.intValue() == XffanType.jifen.getVal()) {

            //校验阅读奖励次数 max
            cout = jifenFlowService.selectCount(new EntityWrapper<JifenFlow>()
                    .eq("uid", uid).eq("jftype", JftypeEnum.yuyue.getVal())
                    .addFilter("date(confirm_date)=date(now())")
            );
            if (cout >= max) {
                logger.info("----------------------------------yuyueFan max=" + max + " cout=" + cout);
                return;
            }

            jifenService.addJifenFlow(uid, user.getMid(), mpid,
                    fan, true, FantimeType.now.getVal(),
                    StringUtil.getSnNo(), IotypeEnum.input, JftypeEnum.yuyue, null, Long.parseLong(ywid));
        } else if (type.intValue() == XffanType.xnbi.getVal()) {
            //校验阅读奖励次数 max
            cout = xnbiFlowService.selectCount(new EntityWrapper<XnbiFlow>()
                    .eq("uid", uid).eq("jftype", JftypeEnum.yuyue.getVal())
                    .addFilter("date(confirm_date)=date(now())")
            );

            if (cout >= max) {
                logger.info("----------------------------------yuyueFan max=" + max + " cout=" + cout);
                return;
            }
            xnbiService.addXnbiFlow(uid, user.getMid(), mpid,
                    fan, true, FantimeType.now.getVal(),
                    StringUtil.getSnNo(), IotypeEnum.input, JftypeEnum.yuyue, null, Long.parseLong(ywid));

        } else if (type.intValue() == XffanType.qian.getVal()) {

            //校验阅读奖励次数max
            cout = accountFlowService.selectCount(new EntityWrapper<AccountFlow>()
                    .eq("uid", uid).eq("xftype", XftypeEnum.yuyue.getVal())
                    .addFilter("date(confirm_date)=date(now())")
            );
            if (cout >= max) {
                logger.info("----------------------------------yuyueFan max=" + max + " cout=" + cout);
                return;
            }
            accountService.addAccountFlow(uid, user.getMid(), mpid,
                    fan, true, FantimeType.now.getVal(),
                    StringUtil.getSnNo(), IotypeEnum.input, XftypeEnum.yuyue, null, Long.parseLong(ywid));
        }
    }

    // 核销返奖励
    private void hexiaoFan(Long uid, Long mpid,String ywid) {

        logger.info("----------------------------------------------------------------------------hexiaoFan come in");
        User user = userService.selectById(uid);

        FanConfig fconfig = redisService.getFanconfig(mpid);
        if (fconfig == null) {
            logger.info("---------------------------------------------------------------------hexiaoFan fconfig is null");
            return;
        }
        BigDecimal fan = fconfig.getHexiaoMount();
        Integer type = fconfig.getHexiaoType();

        if (fconfig == null) {
            logger.info("----------------------------------------------------------------------------hexiaoFan fconfig is null");
            return;
        }
        if (type == null || type == 0) {
            logger.info("----------------------------------------------------------------------------hexiaoFan fconfig is null");
            return;
        }

        if (type.intValue() == XffanType.jifen.getVal()) {

            jifenService.addJifenFlow(uid, user.getMid(), mpid,
                    fan, true, FantimeType.now.getVal(),
                    StringUtil.getSnNo(), IotypeEnum.input, JftypeEnum.hexiao, null, Long.parseLong(ywid));
        } else if (type.intValue() == XffanType.xnbi.getVal()) {
            //校验阅读奖励次数 max
            xnbiService.addXnbiFlow(uid, user.getMid(), mpid,
                    fan, true, FantimeType.now.getVal(),
                    StringUtil.getSnNo(), IotypeEnum.input, JftypeEnum.hexiao, null, Long.parseLong(ywid));

        } else if (type.intValue() == XffanType.qian.getVal()) {

            accountService.addAccountFlow(uid, user.getMid(), mpid,
                    fan, true, FantimeType.now.getVal(),
                    StringUtil.getSnNo(), IotypeEnum.input, XftypeEnum.hexiao, null, Long.parseLong(ywid));
        }
    }

}
